#include <iostream>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <set>
#include <unordered_set>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
const int INF=0x3f3f3f3f;
const int N=2e5+10;
int a[N],b[N];
int solve()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	for(int i=0;i<n;i++)
	{
		cin>>b[i];
	}
	int f=1;
	int sub=0;
	int sub1=0;
	for(int i=0;i<n;i++)
	{
		if(a[i]==b[i])
		{
			if(sub) return 0;
			for(int j=i+1;j<n;j++)
			{
				if(a[j]!=b[j]) return 0;
			}
		}
		if(a[i]<b[i]) return 0;
		if(f && b[i]==0)
		{
			f=-1;
			sub=max(sub,a[i]-b[i]);
			continue;
		}
		if(sub==0)
		{
			sub=a[i]-b[i];
		}
		if(f==-1 && b[i]!=0)
		{
			sub=max(a[i]-b[i],sub);
			f=0;
			
		}
		if(a[i]-sub!=b[i]) return 0;
		
	}

	return 1;
	
	
}
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		if(solve())
		{
			cout<<"YES"<<endl;
		}
		else
		{
			cout<<"NO"<<endl;
		}
	}

	return 0;
}

